unit idispatch_interface;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  ComObj, ActiveX, dJs_TLB, StdVcl, Variants,sysutils;

type
  TTJsToDelphi = class(TAutoObject, ITJsToDelphi)
  protected
    function Get_mLat: OleVariant; safecall;
    procedure Set_mLat(Value: OleVariant); safecall;
    function Get_Bicycling: OleVariant; safecall;
    procedure Set_Bicycling(Value: OleVariant); safecall;
    function Get_MapClick: OleVariant; safecall;
    function Get_lng: OleVariant; safecall;
    procedure Set_lng(Value: OleVariant); safecall;
    function Get_MapRightClick: OleVariant; safecall;
    function Get_MarkerClick: OleVariant; safecall;
    function Get_MarkerDragEnd: OleVariant; safecall;
    function Get_MapDblClick: OleVariant; safecall;
    function Get_MapZoomChange: OleVariant; safecall;
    function Get_zoom: OleVariant; safecall;
    procedure Set_zoom(Value: OleVariant); safecall;

  end;

implementation

uses ComServ, GoogleMap;


function TTJsToDelphi.Get_mLat: OleVariant;
begin
  Result:=map.Lat;
end;

procedure TTJsToDelphi.Set_mLat(Value: OleVariant);
var
  i :integer;
  s :String;
begin
  s:=VarToStr(Value);
  i:=Pos(',',s);
  if i<>0 then s[i]:='.';
  map.Lat:=s;
end;

function TTJsToDelphi.Get_Bicycling: OleVariant;
begin

end;

procedure TTJsToDelphi.Set_Bicycling(Value: OleVariant);
begin

end;


function TTJsToDelphi.Get_MapClick: OleVariant;
begin
  map.MapCklick;
end;

function TTJsToDelphi.Get_lng: OleVariant;
begin
  Result:=map.Lng;
end;

procedure TTJsToDelphi.Set_lng(Value: OleVariant);
var
  i :integer;
  s: string;
begin
  s:=VarToStr(Value);
  i:=Pos(',',s);
  if i<>0 then s[i]:='.';
  map.Lng:=s;
end;

function TTJsToDelphi.Get_MapRightClick: OleVariant;
begin
  map.MapRighCklick;
end;

function TTJsToDelphi.Get_MarkerClick: OleVariant;
begin
  map.Marker.Click;
end;

function TTJsToDelphi.Get_MarkerDragEnd: OleVariant;
begin
  map.Marker.EndDrag;
end;

function TTJsToDelphi.Get_MapDblClick: OleVariant;
begin
  map.DblClick;
end;

function TTJsToDelphi.Get_MapZoomChange: OleVariant;
begin
  map.ZoomChange;
end;

function TTJsToDelphi.Get_zoom: OleVariant;
begin
  Result:=map.MapOptions.zoom;
 // map.JsEx(Format('Zoom(%s)',[map.MapOptions.zoom]));
end;

procedure TTJsToDelphi.Set_zoom(Value: OleVariant);
begin
  map.MapOptions.zoom:=Value;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TTJsToDelphi, Class_TJsToDelphi,
    ciInternal, tmApartment);
end.

